<?php

namespace app\models\db;

use Yii;

/**
 * This is the model class for table "t_mini_programs".
 *
 * @property string $id
 * @property string $name
 * @property string $raw_id
 * @property string $app_id
 * @property string $app_secret
 * @property integer $type
 * @property string $begin_datetime
 * @property string $end_datetime
 * @property integer $is_enabled
 * @property integer $is_deleted
 * @property string $create_datetime
 * @property string $modify_datetime
 * @property string $priavte_key
 * @property string $public_key
 *
 * @property EShop[] $tEShops
 * @property Favourite[] $tFavourites
 * @property MainPage[] $tMainPages
 * @property Order[] $tOrders
 * @property TUser[] $tUsers
 */
class MiniPrograms extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_mini_programs';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id'], 'required'],
            [['type', 'is_enabled', 'is_deleted'], 'integer'],
            [['begin_datetime', 'end_datetime', 'create_datetime', 'modify_datetime'], 'safe'],
            [['id'], 'string', 'max' => 36],
            [['name', 'raw_id', 'app_id', 'app_secret'], 'string', 'max' => 255],
            [['priavte_key'], 'string', 'max' => 2048],
            [['public_key'], 'string', 'max' => 1000],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'raw_id' => 'Raw ID',
            'app_id' => 'App ID',
            'app_secret' => 'App Secret',
            'type' => 'Type',
            'begin_datetime' => 'Begin Datetime',
            'end_datetime' => 'End Datetime',
            'is_enabled' => 'Is Enabled',
            'is_deleted' => 'Is Deleted',
            'create_datetime' => 'Create Datetime',
            'modify_datetime' => 'Modify Datetime',
            'priavte_key' => 'Priavte Key',
            'public_key' => 'Public Key',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTEShops()
    {
        return $this->hasMany(EShop::className(), ['mini_programs_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTFavourites()
    {
        return $this->hasMany(Favourite::className(), ['mini_programs_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTMainPages()
    {
        return $this->hasMany(MainPage::className(), ['mini_programs_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTOrders()
    {
        return $this->hasMany(Order::className(), ['mini_program' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTUsers()
    {
        return $this->hasMany(TUser::className(), ['mini_programes' => 'id']);
    }
}
